#pragma once

#include "VisioCommon.h"
#include "Opencv.h"
#include "Camera.h"

struct SParsedCamera
{
	double f;		//focal point
	double k1;		//distoration coeff 1
	double k2;		//distoration coeff 2
	double R[9];		//Roattion matrix
	double t[3];		//translation vector
	UINT index;			//index of the cam
};


typedef vector<cv::Mat> ImagesVector;

class CBundlerParser
{
public:
	CBundlerParser();
	CBundlerParser(CCameraMesh* pMesh, ImagesVector* pImages);
	void ParseBundle(char* BundleFileName, vector<CMeshInstance*>* pModels);
	void ParseCamera(FILE* pBundleFile, SParsedCamera& newParsedCamera);
	CCamera* ConvertParsedCamera(SParsedCamera* pPCam);
	void CBundlerParser::GetDoubleFromFile(FILE* pFile, UINT NumberOfFloatsToGet, ...) const;
	double CBundlerParser::GetSingleDoubleFromFile(FILE* pFile) const;
	void CBundlerParser::GetDoubleFromFile(FILE* pFile, UINT NumberOfFloatsToGet, double* pDouble) const;

private:
	char* m_BundleFileName;
	CCameraMesh* m_pMesh;
	ImagesVector* m_pImages;
};